package org.yufan.controller.rpc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yufan.bean.Item;
import org.yufan.bean.ItemDesc;
import org.yufan.result.Result;
import org.yufan.result.ResultUtils;
import org.yufan.service.ItemDescService;
import org.yufan.service.ItemService;

/**
 * Created by zxd on 2018/3/28.
 */
@Controller
@RequestMapping("/rpc/item")
public class ItemRpcController {

    private Logger LOGGER= LoggerFactory.getLogger(ItemRpcController.class);

    @Autowired
    private ItemService itemService;

    @Autowired
    private ItemDescService itemDescService;

    @RequestMapping("/queryItem")
    @ResponseBody
    public Result<Item> queryItem(@RequestParam Long itemId){
        LOGGER.info("请求的商品id是{}",itemId);
        Item item = itemService.queryById(itemId);
        return ResultUtils.buildSuccess(item);
    }

    @RequestMapping("/queryItemDesc")
    @ResponseBody
    public Result<ItemDesc> queryItemDesc(@RequestParam Long itemId){
        LOGGER.info("请求的商品id是{}",itemId);
        ItemDesc itemDesc =itemDescService.queryById(itemId);
        return ResultUtils.buildSuccess(itemDesc);
    }


}
